<?php include('header.php'); ?>
	<aside id="side-nav" class="span3">
	<?php include('side.php'); ?>
	</aside>
	<div class="span9 content-container">
		<div id="content-window" class="content">
		<?php
			error_reporting(0);
			$errorMsg = $_GET['errorMsg'];
	
			$userID = $_SESSION['userId'];
	
			$wkshpId = $_POST['submit'];
			
			$con = mysql_connect("localhost", "group5", "group5");
			if(!$con)
			{
				echo "Connection failed!";
				exit;
			}
			
			mysql_select_db("group5");
			
		?>
		
			<?php
			$query = "select * from WORKSHOP_SESSIONS where workshopSessionId = $wkshpId ";
			$table = mysql_query($query,$con);
			$row = mysql_fetch_row($table);
			
			$meetTime = $row[1];
			$meetDate = $row[2];
			$roomId = $row[4];
			
			
			$query2 = "select * from ROOM where roomId = $roomId";
			$table2 = mysql_query($query2, $con);
			$row2 = mysql_fetch_row($table2);
			
			$roomNumber = $row2[2];
			$buildingId = $row2[3];
			
			
			$query3 = "select * from BUILDING where bldgID = $buildingId";
			$table3 = mysql_query($query3, $con);
			$row3 = mysql_fetch_row($table3);
			
			$buildingName = $row3[1];
			
			?>
			
			<p> Change the data below and hit submit to make changes to the course session:</p>
			<form name='create' method='post' action='createSession.php'>
			Meeting Date:      <input type='text' id='date-drop' name='meetdate' value="<?php echo $meetDate; ?>"><br>
			Meeting Time: <input type='text' id="time-drop" name='meetingtime' value="<?php echo $meetTime; ?>"><br>
			Building:     <select id='building' name='building'>
						<option value="<?php echo $buildingName; ?>" selected></option>
						<?php
						$buildingQuery = 'select * from BUILDING';
						$buildingResult = mysql_query($buildingQuery, $con);
						
						while ($buildingRow = mysql_fetch_row($buildingResult))
						{
							$buildingId = $buildingRow[0];
							$buildingName = $buildingRow[1];
							$buildingNum = $buildingRow[2];
							echo "<option value='$buildingId'>$buildingNum - $buildingName</option>";
						}
						?></select><br>
			Room: <select id='room' name='room'>
				  <option value="<?php echo $roomNumber; ?>" selected></option>
				  <?php
						$roomQuery = 'select * from ROOM';
						$roomResult = mysql_query($roomQuery, $con);
						
						while ($roomRow = mysql_fetch_row($roomResult))
						{
							$roomId = $roomRow[0];
							$roomCap = $roomRow[1];
							$roomNum = $roomRow[2];
							echo "<option value='$roomId'>$roomNum - Capacity: $roomCap </option>";
						}
						?><br>
			Workshop:    <select name='category'>
			<option value=''>Select a Workshop</option>
			<?php $table = mysql_query("select * from WORKSHOP", $con);

			while($getRow = mysql_fetch_row($table))
			{
				$workshopId = $getRow[0];
				$title = $getRow[1];
				$descrip = $getRow[2];
				
				 ?><option value ='<?php echo $workshopId;?>'><?php echo $title;?></option><?php
			}?>
			
			</select>
			<br>*Note: We will create a session ID for you. It will be visible on your View/Edit My Sessions page.
			<br><input type='submit' value='Edit This Session'></form>
<?php include('uploadForm.php'); ?>
<p id='regError'><?php echo $errorMsg; ?></p> 

		</div>
	</div> <!-- end .content-container -->
<?php include('footer.php'); ?>
